package org.opens.javaskill.jackson;

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;

@Data
public class JsonObj {

    private static Random random = new Random();

    public JsonObj() {
    }

    public JsonObj(Integer id, String name, Double salary, Date birthday, Date createDate) {
        this.id = id;
        this.name = name;
        this.salary = salary;
        this.birthday = birthday;
        this.createDate = createDate;
    }

    private Integer id;

    private String name;

    private Double salary;

    private Date birthday;

    private Date createDate;

    public static JsonObj init() {
        JsonObj obj = new JsonObj();
        obj.setId(random.nextInt(1000));
        obj.setName("老王");
        obj.setBirthday(new Date());
        obj.setCreateDate(new Date());
        obj.setSalary(random.nextDouble());
        return obj;
    }

    public static List<JsonObj> getList(int initSize) {
        List<JsonObj> result = new ArrayList<>(initSize);
        for (int i = 0; i < initSize; i++) {
            result.add(init());
        }
        return result;
    }

}
